#!/usr/bin/python3
#
# Copyright (C) 2021 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.

import os
import sys

# import Cockpit's machinery for test VMs and its browser test API
TEST_DIR = os.path.dirname(__file__)
sys.path.append(os.path.join(TEST_DIR, "common"))
sys.path.append(os.path.join(os.path.dirname(TEST_DIR), "bots/machine"))

from testlib import MachineCase, nondestructive, test_main  # pylint: disable=import-error

@nondestructive
class TestBasic(MachineCase):

    def testHelp(self):
        b = self.browser

        b.open("/cockpit/@localhost/anaconda-webui/index.html")

        b.click('#continue-btn')

        for page in ['keyboard', 'language', 'timedate', 'installation-source', 'software-selection', 'installation-destination', 'network-hostname', 'root-account', 'user-account']:
            b.click("#" + page)
            b.wait_js_cond(f'window.location.hash === "#/{page}"')
            b.click('#help-btn-' + page)
            b.click('#header-done-btn')
            # TODO replace alert with some real help popup and check the content here

if __name__ == '__main__':
    test_main()
